﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcLogin.Models;
using System.Web.Security;

namespace MvcLogin.Controllers
{
    public class UserController : Controller
    {
        [HttpPost]
        public ActionResult LogIn(User user)
        {
            if (user.UserName == "admin" && user.PassWord == "123")
            {
                FormsAuthentication.SetAuthCookie("admin", true);
                return Json(new HelpClass.JsonData());
            }
            else
            {
                return Json(new HelpClass.JsonData(false,"输入的用户名或密码有误！"));
            }
        }
        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();
            return RedirectToAction("Index","Home");
        }

    }
}
